package com.example.demo.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

/**
 * @Description: TODO
 * @Author zhangguangyan
 * @Date 2023/09/17/ 09:56:36
 */
@Service
public class AsyncService {

    @Async("MyExecutor")
    public   CompletableFuture<List<Integer>> list(List<Integer> list) throws InterruptedException {
        System.out.println(Thread.currentThread().getName());
         Random random = new Random();
            list.add(random.nextInt());
        return CompletableFuture.completedFuture(list);
    }

}
